package com.gcxy.controller;


import com.gcxy.core.PageVO;
import com.gcxy.core.R;
import com.gcxy.dto.guidance.GuidancePageDTO;
import com.gcxy.dto.guidance.UpdateGuidanceDTO;
import com.gcxy.service.GuidanceService;
import com.gcxy.vo.guidance.GuidanceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Huang先森
 * @since 2024-07-22
 */
@Api(value = "GuidanceController", tags = "周指导记录管理")
@RestController
@RequestMapping("/guidance")
public class GuidanceController {

    @Autowired
    private GuidanceService guidanceService;


    @ApiOperation("修改周指导记录")
    @PostMapping("/updateGuidance")
    public R<?> updateGuidance(@RequestBody @Validated UpdateGuidanceDTO updateGuidanceDTO) {
        return guidanceService.updateGuidance(updateGuidanceDTO);
    }

    @ApiOperation("根据id获取周指导记录详情")
    @GetMapping("/getGuidanceById")
    public R<GuidanceVO> getGuidanceById(@RequestParam @NotNull(message = "id不能为空") Integer guidanceId) {
        return guidanceService.getGuidanceById(guidanceId);
    }

    @ApiOperation("分页查询周指导记录")
    @PostMapping("/getGuidanceByPage")
    public R<PageVO<GuidanceVO>> getGuidanceByPage(@RequestBody @Validated GuidancePageDTO guidancePageDTO) {
        return guidanceService.getGuidanceByPage(guidancePageDTO);
    }
}

